import request from '../utils/Request';
export async function getNewsList(data) {
  if(data.artTitle){
    return request(`cm/article/list?artTitle=${data.artTitle}`);
  }else{
    return request(`cm/article/list?artType=${data.artType}`);
  }
}

// 最新资讯
export async function getNewsDetail(artId) {
  return request(`cm/article/${artId}`);
}

// 推荐课程 listByClassif
// export async function listByClassif(courseClassif="") {
export async function listByClassif(data) {
  if(data.courseTitle){
    return request(
      `content/course/listByClassif?courseTitle=${data.courseTitle}`,
    );
  }else{
    return request(
      `content/course/listByClassif?ps=${data.ps}&courseClassif=${data.courseClassif}&teacherId=${data.teacherId}`,
    );
  }
}

// 课程详情 courseDetail
export async function courseDetail(courseId) {
  return request(`content/course/${courseId}`);
}

// 课程目录 courseCataList
export async function courseCataList(courseId) {
  return request(`content/catalog/list?artId=${courseId}`);
}

// 客户列表 custList
export async function custList(data) {
  return request(`system/cust/list?status=0&custType=${data.custType}`);
}

// 客户详情 custDetail
export async function custDetail(custId) {
  return request(`system/cust/${custId}`);
}

// 优惠券
export async function couponcustList({custId, couponCustStatus}) {
  return request(
    `market/couponcust/list?custId=${custId}&couponCustStatus=${couponCustStatus}`,
  );
}

// profile
export async function profile() {
  return request('system/user/profile');
}

// 创建订单
export async function createOrder(data) {
  return request('sm/order', {
    body: data,
    method: 'POST',
  });
}

// 更新订单
export async function updateOrder(data) {
  return request('sm/order', {
    body: data,
    method: 'PUT',
  });
}

// 计算优惠金额

export async function orderCalculateAmt(data) {
  return request('sm/order/calculate/amt', {
    body: data,
    method: 'POST',
  });
}

// 生成支付宝支付字符串
export async function alipayAppPay(data) {
  return request('alipay/appPay', {
    body: data,
    method: 'POST',
  });
}

// 微信支付签名生成

export async function wxpayAppPay(data) {
  return request('wxpay/appPay', {
    body: data,
    method: 'POST',
  });
}

// 重新支付
export async function resetPay({orderId}) {
  return request(`sm/order/${orderId}`);
}

// 首页广告 advert
export async function advert() {
  return request('content/advert/firstPageList');
}
